//
//  User.m
//  bookKTVMerchant
//
//  Created by edz on 2019/7/22.
//  Copyright © 2019年 edz. All rights reserved.
//

#import "User.h"
@interface User()
@property(nonatomic,strong)NSUserDefaults *userDefaults;

@end

@implementation User
- (NSUserDefaults *)userDefaults{
    if (!_userDefaults) {
        _userDefaults = [NSUserDefaults standardUserDefaults];
        
    }
    return _userDefaults;
}

+(User *)sharedUUser{
    static User *sharedUserInstance =nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        sharedUserInstance = [[User alloc]init];
        
        
        
    });
    return sharedUserInstance;
}

- (NSString *)user_phone{
    
    return [self.userDefaults objectForKey:@"phone"];
    
}

- (void)setUser_phone:(NSString *)user_phone{
      [self.userDefaults setObject:user_phone forKey:@"phone"];
    
}
//-(NSString *)usre_sign{
//    return [self.userDefaults objectForKey:@"sign"];
//}
//
//-(void)setUsre_sign:(NSString *)usre_sign{
//    [self.userDefaults setObject:usre_sign forKey:@"sign"];
//}

-(NSString *)user_id{
    return [self.userDefaults objectForKey:@"user_id"];
}
- (void)setUser_id:(NSString *)user_id{
     [self.userDefaults setObject:user_id forKey:@"user_id"];
}


-(NSString *)user_name{
    return [self.userDefaults objectForKey:@"name"];
}


-(NSString *)user_year{
    return [self.userDefaults objectForKey:@"year"];
    
    
}
-(void)setUser_year:(NSString *)user_year{
     [self.userDefaults setObject:user_year forKey:@"year"];
    
}

-(void)setUser_name:(NSString *)user_name{
    [self.userDefaults setObject:user_name forKey:@"name"];
}
- (BOOL)isLogin{
    
    return self.user_phone?YES :NO;
}

- (NSString *)user_imageViewName{
    
    return [self.userDefaults objectForKey:@"imageViewName"];
    
}

-(void)setUser_imageViewName:(NSString *)user_imageViewName{
    
     [self.userDefaults setObject:user_imageViewName forKey:@"imageViewName"];
   
    
}
- (NSString *)user_signer{
    
     return [self.userDefaults objectForKey:@"signer"];
    
    
    
}
-(void)setUser_signer:(NSString *)user_signer{
    
      [self.userDefaults setObject:user_signer forKey:@"signer"];
    
}

- (BOOL)isLogout{
    
    [self.userDefaults removeObjectForKey:@"phone"];
    
    
    if (self.user_phone.length<=0) {
        return YES;
    }
    else{
        
        
        
        return NO;
    }
    
}

- (BOOL)isCertification{
    
    return self.user_year?YES :NO;
}

@end
